from django.apps import AppConfig


class IdentifyConfig(AppConfig):
    default_auto_field = "django.db.models.BigAutoField"
    name = "identify"
    verbose_name = "Identify"
    verbose_name_plural = "Identify"

    # 应用加载完成后 Django 自动调用的方法
    def ready(self):
        from django.contrib.auth import get_user_model
        import logging

        logger = logging.getLogger(__name__)

        User = get_user_model()
        if not hasattr(User, "email"):
            raise RuntimeError("自定义 User 模型必须包含 email 字段")

        logger.info("Identify 应用已加载，User 模型包含 email 字段")
